package com.bwie.startup;
import com.bwie.common.domain.Prize;
import com.bwie.mapper.LottoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

@Component
public class LottoAutoUp implements ApplicationRunner {



    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private LottoMapper lottoMapper;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<Prize> prizes = lottoMapper.selectPrize();
        String redisKey="prizes:list";
        redisTemplate.opsForValue().set(redisKey,prizes);

    }

}
